<?php	 	 

/**
 * This is the model class for table "data_kepegawaian".
 *
 * The followings are the available columns in table 'data_kepegawaian':
 * @property integer $id
 * @property string $nip
 * @property string $nama
 * @property string $tempat_lahir
 * @property string $tanggal_lahir
 * @property integer $jenis_kelamin
 * @property integer $agama
 * @property string $alamat
 * @property string $telepon
 * @property string $email
 * @property integer $status_pernikahan
 * @property integer $jumlah_anak
 * @property integer $bidang
 * @property integer $status_pegawai
 * @property integer $golongan_cpns
 * @property integer $jabatan_struktural
 * @property integer $jabatan_funsional
 * @property string $photo
 *
 * The followings are the available model relations:
 * @property Master $jabatanFunsional
 * @property Master $jenisKelamin
 * @property Master $agama0
 * @property Master $statusPernikahan
 * @property Master $bidang0
 * @property Master $statusPegawai
 * @property Master $golonganCpns
 * @property Master $jabatanStruktural
 * @property DokumentasiPelaksanaanKegiatan[] $dokumentasiPelaksanaanKegiatans
 */
class DataKepegawaian extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return DataKepegawaian the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'data_kepegawaian';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('nip, nama, tempat_lahir, tanggal_lahir, jenis_kelamin, agama, email, status_pernikahan', 'required'),
			array('jenis_kelamin, agama, status_pernikahan, jumlah_anak, bidang, status_pegawai, golongan_cpns, jabatan_struktural, jabatan_funsional', 'numerical', 'integerOnly'=>true),
			array('nip, tempat_lahir, telepon, email', 'length', 'max'=>50),
			array('nama, photo', 'length', 'max'=>255),
			array('alamat, satker', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, nip, nama, tempat_lahir, tanggal_lahir, jenis_kelamin, agama, alamat, telepon, email, status_pernikahan, jumlah_anak, satker, bidang, status_pegawai, golongan_cpns, jabatan_struktural, jabatan_funsional, photo', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'jabatanFunsional' => array(self::BELONGS_TO, 'Master', 'jabatan_funsional'),
			'jenisKelamin' => array(self::BELONGS_TO, 'Master', 'jenis_kelamin'),
			'agama0' => array(self::BELONGS_TO, 'Master', 'agama'),
			'statusPernikahan' => array(self::BELONGS_TO, 'Master', 'status_pernikahan'),
			'bidang0' => array(self::BELONGS_TO, 'Master', 'bidang'),
			'statusPegawai' => array(self::BELONGS_TO, 'Master', 'status_pegawai'),
			'golonganCpns' => array(self::BELONGS_TO, 'Master', 'golongan_cpns'),
			'jabatanStruktural' => array(self::BELONGS_TO, 'Master', 'jabatan_struktural'),
			'jabatanFungsi' => array(self::BELONGS_TO, 'Master', 'jabatan_funsional'),
			'satker' => array(self::BELONGS_TO, 'Satker', 'satker'),
		);
	}
	
	public function findPegawai(){
		$pegawais = $this->findAll();
		$i=0;
		foreach ($pegawais as $a) :
		$pegawai[$i]=$a->nama;
		$i++;
		endforeach;
	return $pegawai;
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'nip' => 'Nip',
			'nama' => 'Nama',
			'tempat_lahir' => 'Tempat Lahir',
			'tanggal_lahir' => 'Tanggal Lahir',
			'jenis_kelamin' => 'Jenis Kelamin',
			'agama' => 'Agama',
			'alamat' => 'Alamat',
			'telepon' => 'Telepon',
			'email' => 'Email',
			'status_pernikahan' => 'Status Pernikahan',
			'jumlah_anak' => 'Jumlah Anak',
			'satker' => 'Satuan Kerja',
			'bidang' => 'Bidang',
			'status_pegawai' => 'Status Pegawai',
			'golongan_cpns' => 'Golongan Cpns',
			'jabatan_struktural' => 'Jabatan Struktural',
			'jabatan_funsional' => 'Jabatan Funsional',
			'photo' => 'Photo',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('nip',$this->nip,true);
		$criteria->compare('nama',$this->nama,true);
		$criteria->compare('tempat_lahir',$this->tempat_lahir,true);
		$criteria->compare('tanggal_lahir',$this->tanggal_lahir,true);
		$criteria->compare('jenis_kelamin',$this->jenis_kelamin);
		$criteria->compare('agama',$this->agama);
		$criteria->compare('alamat',$this->alamat,true);
		$criteria->compare('telepon',$this->telepon,true);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('status_pernikahan',$this->status_pernikahan);
		$criteria->compare('jumlah_anak',$this->jumlah_anak);
		$criteria->compare('satker',$this->satker,true);
		$criteria->compare('bidang',$this->bidang);
		$criteria->compare('status_pegawai',$this->status_pegawai);
		$criteria->compare('golongan_cpns',$this->golongan_cpns);
		$criteria->compare('jabatan_struktural',$this->jabatan_struktural);
		$criteria->compare('jabatan_funsional',$this->jabatan_funsional);
		$criteria->compare('photo',$this->photo,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}